
//
// 120312 - AH - (Chaos *) Created.
// 120313 - AH - Made Serializable.
//

package org.soekrat.server.serialization;

import java.io.Serializable;

/**
 * <p>
 *   Describes matching strategy.
 * </p>
 * @author Arne Halvorsen (AH)
 * @author Laetitia Le Chatton (LLC) 
 */
public final class MatchingStrategySerializable implements Serializable
{
  private static final long serialVersionUID=6658385196573228659L;

  private String algorithm="leveinstein";
  
  private float value=0.3f;
  
  /**
   * <p>
   *   Constructor.
   * </p>
   */
  public MatchingStrategySerializable(){}
 
  /**
   * <p>
   *   Sets name on word distance algorithm.
   * </p>
   * @param algorithm Name on algorithm.
   * @return {@code this}.
   */
  public MatchingStrategySerializable algorithm(String algorithm)
  {
    if (algorithm==null)
    {
      throw new NullPointerException("algorithm");
    }
    
    this.algorithm=algorithm;
    
    return this;
  }
  
  /**
   * <p>
   *   Gets name on word distance algorithm.
   * </p>
   * @return Name.
   */
  public String algorithm(){ return algorithm; }
  
  /**
   * <p>
   *   Sets sensitivity level. 
   * </p>
   * @param v Level.
   * @return {@code this}.
   * @throws IllegalArgumentException If {@code v<0.0 || v>1.0}.
   */
  public MatchingStrategySerializable value(float v)
  {
    if (v<0.0f || v>1.0f)
    {
      throw new IllegalArgumentException("v<0.0f || v>1.0f : "+v);
    }
    
    value=v;
    
    return this;
  }
  
  /**
   * <p>
   *   Gets sensitivity level. 
   * </p>
   * @return Level.
   */
  public float value(){ return value; }
  
}
